package com.cpi.basilos.reason.movement.converter;

import org.apache.log4j.Logger;

import com.cpi.basilos.reason.movement.dto.ReasonMovementDTO;
import com.cpi.basilos.reason.movement.exception.ReasonMovementException;
import com.cpi.basilos.reason.movement.view.ReasonMovementView;
import com.cs.common.exception.CSException;

public class ReasonMovementConverter {
	private static org.apache.log4j.Logger logger = Logger.getLogger(ReasonMovementConverter.class);
	public ReasonMovementView convertDTOToView(ReasonMovementDTO reasonMovementDTO)throws ReasonMovementException{
		ReasonMovementView reasonMovementView = null;
		try{
			reasonMovementView = new ReasonMovementView();
			reasonMovementView.setId(reasonMovementDTO.getId());
			reasonMovementView.setCode(reasonMovementDTO.getCode().toUpperCase());
			reasonMovementView.setDescription(reasonMovementDTO.getDescription().toUpperCase());
		}catch( Exception exception ){
			ReasonMovementException reasonMovementException = null;
			logger.error(exception);
			exception.printStackTrace(System.err);
			reasonMovementException = new ReasonMovementException(exception,CSException.LAYER_CONVERTER, CSException.ACTION_SELECT);
			throw reasonMovementException;
		}
		return reasonMovementView;
	}
}